import Vue from "vue";
import VueRouter from "vue-router";
// import login from "@/views/login";不进行加载需要一个一个的导入
Vue.use(VueRouter);

const routes = [
  // 路由懒加载，当访问这个路由的时候才去加载对应的代码，提高售票加载的速度
  {
    path: "/",
    redirect: "/Layout",
  },
  {
    path: "/Login",
    component: () => import("@/views/Login/index.vue"),
  },
  {
    path: "/Search",
    component: () => import("@/views/Search/index.vue"),
  },
  {
    path: "/GoodsList",
    component: () => import("@/views/GoodsList/index.vue"),
  },
  {
    path: "/GoodsDetails",
    component: () => import("@/views/GoodsDetails/index.vue"),
  },
  {
    path: "/Register",
    component: () => import("@/views/Register/index.vue"),
  },
  {
    path: "/Layout",
    component: () => import("@/views/Layout/index.vue"),
    redirect: "/Layout/Home",
    children: [
      {
        path: "Home",
        component: () => import("@/views/Layout/Home"),
      },
      {
        path: "Car",
        component: () => import("@/views/Layout/Car"),
      },
      {
        path: "Mine",
        component: () => import("@/views/Layout/Mine"),
      },
    ],
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
